package Entidad;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "afiliado")
@NamedQueries({@NamedQuery(name = "Afiliado.findAll", query = "SELECT a FROM Afiliado a"), @NamedQuery(name = "Afiliado.findByCedula", query = "SELECT a FROM Afiliado a WHERE a.cedula = :cedula"), @NamedQuery(name = "Afiliado.findByNombre", query = "SELECT a FROM Afiliado a WHERE a.nombre = :nombre"), @NamedQuery(name = "Afiliado.findByContraseña", query = "SELECT a FROM Afiliado a WHERE a.contraseña = :contraseña"), @NamedQuery(name = "Afiliado.findByEdad", query = "SELECT a FROM Afiliado a WHERE a.edad = :edad"), @NamedQuery(name = "Afiliado.findBySexo", query = "SELECT a FROM Afiliado a WHERE a.sexo = :sexo")})
public class Afiliado implements Serializable {

    private static final long serialVersionUID = 1L;

    /*llave primaria*/
    @Id
    @Column(name = "cedula",nullable= false)
    private Integer cedula;
    
    /*relaciones uno a uno*/
    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="id_rutina",nullable = false,referencedColumnName="id")
    private Rutina rutina;
    
    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="id_rep_afi",nullable = false,referencedColumnName="id")
    private Reporteafiliado reporteAfiliado;

    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="id_rep_med",nullable = false,referencedColumnName="id")
    private Reportemedico reporteMedico;

    /*atributos relaciones muchos a uno*/
    @ManyToOne
    @JoinColumn(name="id_fisioterapeuta",nullable = false, referencedColumnName="cedula")
    private Fisioterapeuta fValorador;

    @ManyToOne
    @JoinColumn(name="id_deportologo",nullable = false,referencedColumnName="cedula")
    private Deportologo dValorador;
    
    /*atributos primitivos*/
    @Column(name = "nombre",nullable = false)
    private String nombre;

    @Column(name = "contraseña",nullable = false)
    private String contraseña;

    @Column(name = "edad",nullable = false)
    private int edad;

    @Column(name = "sexo",nullable = false)
    private String sexo;

    public Afiliado() {
    }

    public Integer getCedula() {
        return cedula;
    }

    public void setCedula(Integer cedula) {
        this.cedula = cedula;
    }

    public String getContraseña() {
        return contraseña;
    }

    public void setContraseña(String contraseña) {
        this.contraseña = contraseña;
    }

    public Deportologo getDValorador() {
        return dValorador;
    }

    public void setDValorador(Deportologo dValorador) {
        this.dValorador = dValorador;
    }

    public int getEdad() {
        return edad;
    }

    public void setEdad(int edad) {
        this.edad = edad;
    }

    public Fisioterapeuta getFValorador() {
        return fValorador;
    }

    public void setFValorador(Fisioterapeuta fValorador) {
        this.fValorador = fValorador;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Reporteafiliado getReporteAfiliado() {
        return reporteAfiliado;
    }

    public void setReporteAfiliado(Reporteafiliado reporteAfiliado) {
        this.reporteAfiliado = reporteAfiliado;
    }

    public Reportemedico getReporteMedico() {
        return reporteMedico;
    }

    public void setReporteMedico(Reportemedico reporteMedico) {
        this.reporteMedico = reporteMedico;
    }

    public Rutina getRutina() {
        return rutina;
    }

    public void setRutina(Rutina rutina) {
        this.rutina = rutina;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cedula != null ? cedula.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Afiliado)) {
            return false;
        }
        Afiliado other = (Afiliado) object;
        if ((this.cedula == null && other.cedula != null) || (this.cedula != null && !this.cedula.equals(other.cedula))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidad.Afiliado[cedula=" + cedula + "]";
    }

}
